<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>企业基础信息录入</title>
<link rel="stylesheet" href="<s:url value="/theme/base/jquery.ui.core.css"/>">
<link rel="stylesheet" href="<s:url value="/theme/base/jquery.ui.resizable.css"/>">
<link rel="stylesheet" href="<s:url value="/theme/base/jquery.ui.theme.css"/>">
<link rel="stylesheet" href="<s:url value="/css/form.css"/>">
<script src="<s:url value="/script/jquery-1.7.2.js"/>"></script>
<script src="<s:url value="/script/jquery.form.js"/>"></script>
<script src="<s:url value="/script/jquery.validate.min.js"/>"></script>
<script src="<s:url value="/script/jquery.validate.custom.js"/>"></script>
<script src="<s:url value="/theme/script/jquery.ui.core.js"/>"></script>
<script src="<s:url value="/theme/script/jquery.ui.widget.js"/>"></script>
<script src="<s:url value="/theme/script/jquery.ui.mouse.js"/>"></script>
<script src="<s:url value="/theme/script/jquery.ui.resizable.js"/>"></script>
<script type="text/javascript">
	$(function() {
		$("textarea").resizable({helper: "ui-state-highlight"});
		$("input:text").resizable({helper: "ui-state-highlight"});
		
		$(document).ready(function() {
			jQuery.validator.addMethod("unionCorp", function(value, element) {
				var params = {corpName : value};
				$.ajax({
					type: "POST",
					url :"/info/p_doCorpUniqueValidate.action",
					data: params,
					dataType:"text",
					async : false,
					error: function(request) {
					    alert("服务器异常！");
					},
					success: function(data) {
					}
				});
			}, "该企业信息已经被收录！");
		});
		
		$("#infoForm").validate({
			debug : true,
			onkeyup : false,
			rules: {
				p_corp_name: {
					required: true,
					minlength: 2,
					remote:{
	                	type:"post",
	                	async:true,
	                	url:"<s:url value='/info/p_doCorpUniqueValidate.action'/>",
	                	data:{
	                		corpName : function(){ return $("#p_corp_name").val(); }
	                	}
                	}
				},
				p_linker: {
					required: true,
					minlength: 5
				},
				p_email: {
					required: true,
					moreEmail: true
				}
			},
			messages: {
				p_corp_name: {
					remote : "该企业已经被收录 ... "
				}
			},
			errorPlacement: function(error, element) {   
			    error.appendTo(element.parent());   
			},
			submitHandler : function(){
				mySubmit();
				return false;
			}
		});
	});
	
	mySubmit = function(){
		var options = { 
	        success:   msgBack,  // post-submit callback 
	        dataType:  'text' ,     // 'xml', 'script', or 'json' (expected server response type) 
	        clearForm: true  ,      // clear all form fields after successful submit 
	        resetForm: true  ,      // reset the form after successful submit 
	        timeout:   3000 
	    }; 
	    $('#infoForm').ajaxSubmit(options); 
	};
	
	function msgBack(responseText, statusText, xhr, $form)  { 
		if(responseText=="yes"){
		 alert("信息成功录入！");
		}else{
		 alert("信息录入失败!");
		}
	} 
</script>
<style type="text/css">
</style>
</head>
<body>
	<form id="infoForm" action="<s:url value="/info/p_doInput.action"/>" method="post" class="infoForm">
	  <table width="574" border="0">
	    <tr>
	      <td width="74">
	      	<div align="right">关键字：</div>
	      </td>
	      <td width="500">
			<label for="p_keyword"></label>
			<input type="text" name="p_keyword" id="p_keyword">
          </td>
        </tr>
	    <tr>
	      <td><div align="right">所属国家：</div></td>
	      <td><label for="p_country"></label>
          <input type="text" name="p_area_id" id="p_area_id"></td>
        </tr>
	    <tr>
	      <td><div align="right">公司名称：</div></td>
	      <td><label for="p_corp_name"></label>
          <input type="text" name="p_corp_name" id="p_corp_name">
          </td>
        </tr>
	    <tr>
	      <td><div align="right">联系人：</div></td>
	      <td><label for="p_linker"></label>
          <input type="text" name="p_linker" id="p_linker"></td>
        </tr>
	    <tr>
	      <td><div align="right">邮箱：</div></td>
	      <td><label for="p_email"></label>
          <textarea name="p_email" id="p_email" cols="30" rows="5"></textarea>
          </td>
        </tr>
	    <tr>
	      <td><div align="right">电话：</div></td>
	      <td><label for="p_phone"></label>
          <textarea name="p_phone" id="p_phone" cols="30" rows="5"></textarea>
          </td>
        </tr>
	    <tr>
	      <td><div align="right">手机：</div></td>
	      <td><label for="p_mobile"></label>
          <textarea name="p_mobile" id="p_mobile" cols="30" rows="5"></textarea>
          </td>
        </tr>
	    <tr>
	      <td><div align="right">传真：</div></td>
	      <td><label for="p_fax"></label>
          <textarea name="p_fax" id="p_fax" cols="30" rows="5"></textarea>
          </td>
        </tr>
	    <tr>
	      <td><div align="right">来源网站：</div></td>
	      <td><label for="p_origin_site"></label>
          <input type="text" name="p_origin_site" id="p_origin_site"></td>
        </tr>
	    <tr>
	      <td><div align="right">官方网站：</div></td>
	      <td><label for="p_home_page"></label>
          <input type="text" name="p_home_page" id="p_home_page"></td>
        </tr>
	    <tr>
	      <td><div align="right">备注：</div></td>
	      <td><label for="p_remark"></label>
          <textarea name="p_remark" id="p_remark" cols="30" rows="5"></textarea>
          </td>
        </tr>
	    <tr>
	      <td><div align="right">
	        <input type="submit" name="button" id="button" value="提交">
          </div></td>
	      <td><div align="center">
	        <input type="reset" name="button2" id="button2" value="取消">
          </div></td>
        </tr>
      </table>
	</form>
</body>
</html>